package com.tt.fashionWebSite.dao.jpa;

import com.tt.fashionWebSite.dao.KetQuaTuVanDao;
import com.tt.fashionWebSite.domain.KetQuaTuVan;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by isoft-work 5 on 1/1/2015.
 */
@Repository("ketQuaTuVan")
public class KetQuaTuVanJpaDao extends GenericJpaDao<KetQuaTuVan, Long> implements KetQuaTuVanDao {
   public KetQuaTuVanJpaDao(){
      super(KetQuaTuVan.class);
   }

   @Override
   public KetQuaTuVan getInfoConsultantByUser (String maTV, String gender) {
      List<KetQuaTuVan> ketQuaTuVans = getEntityManager().createNamedQuery(KetQuaTuVan.GET_INFO_BY_USER, KetQuaTuVan.class)
            .setParameter("maTV", maTV)
            .setParameter("gender", gender)
            .getResultList();
      if(ketQuaTuVans != null && ketQuaTuVans.size() > 0) {
         return ketQuaTuVans.get(0);
      }
      return null;
   }
}
